import request from '../../request/request_axios.js'

/**
 * 预约挂号
 * @param {Object} bookingData - 预约信息
 * @param {number} bookingData.ruleId - 排班规则ID
 * @param {string} bookingData.medicalRecordNumber - 就诊人病历号
 * @returns {Promise} 返回预约结果
 */
export const bookingAPI = (bookingData) => {
  return request({
    url: '/bookings/booking',
    method: 'put',
    data: bookingData
  });
};

/**
 * 查看个人预约记录
 * @param {number} [status=-1] - 预约状态，-1表示查询所有状态
 * @returns {Promise} 返回预约记录列表
 */
export const getMyBookingsAPI = (status = -1) => {
  return request({
    url: '/bookings/myBooking',
    method: 'get',
    params: { status }
  });
};

/**
 * 根据挂号ID查询挂号信息
 * @param {number} bookingId - 挂号ID
 * @returns {Promise} 返回挂号详细信息
 */
export const getBookingByIdAPI = (bookingId) => {
  return request({
    url: `/bookings/getBookingById/${bookingId}`,
    method: 'get'
  });
};

/**
 * 更新预约状态为已支付（待就诊）
 * @param {number} bookingId - 挂号ID
 * @returns {Promise} 返回更新结果
 */
export const updateBookingStatusAPI = (bookingId) => {
  return request({
    url: `/bookings/updateStatusToPaid/${bookingId}`,
    method: 'put',
  });
};